package com.etrans.web.gps.business.base.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.etrans.web.gps.base.service.BaseService;
import com.etrans.web.gps.business.base.domain.SimCardVO;



@Service
public class SimCardService extends BaseService{

	public List<SimCardVO> querySimCardList( Map<String, Object> paramMap) {
		List<SimCardVO> list = selectList("simCardQuery.querySimCardList", paramMap);
		return list;
	}

	public Integer querySimCardListCount( Map<String, Object> param) {
		return (Integer) this.selectOne("simCardQuery.querySimCardListCount", param);
	}

	public SimCardVO querySimCardById( Integer id) {
		SimCardVO simcard = (SimCardVO) this.selectOne("simCardQuery.querySimCardById", id);
		return simcard;
	}

	public int queryCountByPhoneNO(HashMap<String, Object> parms) {
		return(Integer) this.selectOne("simCardQuery.queryCountByPhoneNO", parms);
	}
	@Transactional(readOnly = false, rollbackFor = { DataAccessException.class, Exception.class })
	public void updateSimCard( SimCardVO simcard) {
		this.update("simCardrMapper.updateSimCard", simcard);
	}
	@Transactional(readOnly = false, rollbackFor = { DataAccessException.class, Exception.class })
	public void saveSimCard( SimCardVO simcard) {
		this.insert("simCardrMapper.saveSimCard", simcard);
	}
	@Transactional(readOnly = false, rollbackFor = { DataAccessException.class, Exception.class })
	public void deleteSimCardByID(int id, HttpServletRequest request) {
		//删除sim卡信息
		//SimCardVO simCard = querySimCardById(id);
		this.delete("simCardrMapper.deleteSimCardByID", id);
		//更新对应终端信息的状态为未使用
		this.update("simCardrMapper.batchUpdateTerminalStatusSQL", id);
		/*String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
		StringBuffer buffer = new StringBuffer();
		buffer.append("删除SIM卡信息->SIM卡号:(" + simCard.getCode() + "),");*/
		
	}

	public List querySimCardsTrees( HashMap<String, Object> paramMap) {
		List list = this.selectList("simCardQuery.querySimCardsTrees", paramMap);
		 return list;
	}

	public List<SimCardVO> querySimCardExportList(Map<String, Object> paramMap) {
		List<SimCardVO> list = selectList("simCardQuery.querySimCardExportList", paramMap);
		return list;
	}
	
	public Integer queryIDByPhoneNO(HashMap<String, Object> param) {
		return(Integer) this.selectOne("simCardQuery.queryIDByPhoneNO", param);
	}

}
